package com.ruoyi.mapper;


import com.ruoyi.domain.AdvBroadcast;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * Mapper接口
 *
 * @author ruoyi
 * @date 2024-05-13
 */
public interface AdvBroadcastMapper
{
    @Delete("delete from  adv_broadcast")
    public int clear();

    /**
     * 查询
     *
     * @param advBroadcastId 主键
     * @return
     */
    public AdvBroadcast selectAdvBroadcastByAdvBroadcastId(Long advBroadcastId);

    /**
     * 查询列表
     *
     * @param advBroadcast
     * @return 集合
     */
    public List<AdvBroadcast> selectAdvBroadcastList(AdvBroadcast advBroadcast);

    public List<AdvBroadcast> selectAdvBroadcastListApp(AdvBroadcast advBroadcast);

    /**
     * 新增
     *
     * @param advBroadcast
     * @return 结果
     */
    public int insertAdvBroadcast(AdvBroadcast advBroadcast);

    /**
     * 修改
     *
     * @param advBroadcast
     * @return 结果
     */
    public int updateAdvBroadcast(AdvBroadcast advBroadcast);

    /**
     * 删除
     *
     * @param advBroadcastId 主键
     * @return 结果
     */
    public int deleteAdvBroadcastByAdvBroadcastId(Long advBroadcastId);

    /**
     * 批量删除
     *
     * @param advBroadcastIds 需要删除的数据主键集合
     * @return 结果
     */
    public int deleteAdvBroadcastByAdvBroadcastIds(Long[] advBroadcastIds);

    @Update("update adv_broadcast set broadstatus = 1 where adv_members_id = #{advMembersId} " +
            "and endtime > #{currentTime} and begintime < #{currentTime}")
    int startLive(@Param("advMembersId") Long advMembersId, @Param("currentTime") String currentTime);

    @Update("update adv_broadcast set broadstatus = 3 where adv_members_id = #{advMembersId} " +
            "and broadstatus = 1")
    int stopLive(Long advMembersId);

    List<AdvBroadcast> getBroadByDevicesno(@Param("devicesno") String devicesno, @Param("advMembersId") String advMembersId);
    //删除会员直播预约表
    void deleteReservbroadcast(Long[] advBroadcastIds);
    //设备与视频内容直播关联表
    void deleteDeservbroadcast(Long[] advBroadcastIds);

    @Delete("delete from adv_broadcast   where adv_members_id=#{advMembersId}")
    void deleteByAdvMembersId(String valueOf);

    @Select("select broadstatus, reason from adv_broadcast where adv_members_id = #{advMembersId} " +
            "and is_audit = 1")
    AdvBroadcast status(String advMembersId);

    void checkBroadStatus();

}
